function edit_information(){
	window.location = BASE_URI+'seller/my_account/edit_information';	
}

function change_password(){
	window.location = BASE_URI+'seller/my_account/change_password';
}

function change_email(){
	window.location = BASE_URI+'seller/my_account/change_email';
}

google.setOnLoadCallback(function() {
	var options = { 
        beforeSubmit:  validateB4Submit,   
        success:       processAfterResponding   
    };	
	$('#submit_information').ajaxForm(options); 
	
	var option2 = { 
        beforeSubmit:  validateB4SubmitPasswd,  
        success:       processAfterRespondingPasswd 
    };	
	$('#submit_password').ajaxForm(option2); 
	
	var option3 = { 
        beforeSubmit:  validateB4SubmitShow,  
        success:       processAfterRespondingShow
    };	
	$('#submit_show').ajaxForm(option3); 
	$('#edit_show').ajaxForm(option3);
	
	var option4 = {
		beforeSubmit:  validateB4SubmitEmail,  
        success:       processAfterRespondingEmail
	};
	$('#submit_email').ajaxForm(option4);
});

function validateB4SubmitEmail(formData, jqForm, options){
	$('#loader').show();
	if(!isEmail($('#new_email').val())){
		$('#new_email_error').removeClass('hidden');
		$('#loader').hide();
		return false;
	}
	return true;
}

function processAfterRespondingEmail(responseText, statusText, xhr, $form){
	$('#loader').hide();
	var arr_res = responseText.split('#');
	if(arr_res[0] == 'err'){
		$('#target_err').html(arr_res[1]).show();
	}else{
		window.location = BASE_URI+'seller/my_account/change_email_notify';
	}
}

function validateB4SubmitShow(formData, jqForm, options){
	$('#loader').show();
	var array_err = ['show_name_error', 'artist_error', 'bid_open_error', 'music_genre_error', 'speaker_profile_error', 'plays_musicals_error', 'period_error','bid_due_date_error', 'available_for_error', 'entourage_no_error', 'min_bid_error', 'tech_rider_error', 'show_image_error', 'hospitality_rider_error'];
	for(i in array_err){
		$('#'+array_err[i]).addClass('hidden');
	}
}

function processAfterRespondingShow(responseText, statusText, xhr, $form){
	$('#loader').hide();
	var arr_res = responseText.split('#');
	if(arr_res[0] == 'err'){
		for(i in arr_res){
			$('#'+arr_res[i]+'_error').removeClass('hidden');
		}
	}else{
		window.location = arr_res[1];//BASE_URI+'seller/add_show/add_notify';
	}
	
}

function validateB4SubmitPasswd(formData, jqForm, options){
	$('#loader').show();
	if( $('#current_password_md5').val() != md5($('#current_password').val()) ){
		$('#current_password_error').removeClass('hidden');
		$('#loader').hide();
		return false;
	}else{
		if(isEmpty($('#new_password').val())){
			$('#new_password_error').removeClass('hidden');
			$('#loader').hide();
			return false;
		}else{
			$('#loader').show();
			$('#new_password_error').addClass('hidden');
			$('#current_password_error').addClass('hidden');
			return true;
		}
	}
	return true;
}

function processAfterRespondingPasswd(responseText, statusText, xhr, $form) {
	$('#loader').hide();	
	 
	if(responseText == 'ok'){
		window.location = BASE_URI+'seller/my_account/change_password_notify';
	}
}

function validateB4Submit(formData, jqForm, options){
	$('#loader').show();
	
	json = {};
	for( e in formData){
		json[formData[e].name] = formData[e].value;
	}
	
	var arrayRequire = ['first_name','last_name','job_title','company','country','address_line_1','city','state','zip','work_phone']; 
	var err = 0;
	for(var i=0 ;i< arrayRequire.length; i++ ){
		if( isEmpty(json[arrayRequire[i]]) ){
			$('#'+arrayRequire[i]+'_error').show();
			err++;
		}else{
			$('#'+arrayRequire[i]+'_error').hide();
		}
	}
	
	if(err > 0){	
		$('#loader').hide();
		self.scrollTo(200,200);
		return false;
	}else{
		return true;
	}
}


function processAfterResponding(responseText, statusText, xhr, $form) {
	$('#loader').hide();	
	 
	if(responseText == 'ok'){
		window.location = BASE_URI+'seller/my_account/edit_information_notify';
	}
}